package org.indi.yudidi;

import sun.reflect.Reflection;

/**
 * Created by didi on 30/06/2018.
 */

class Test {
    public static void main(String[] args) {
        new TestGetCallerClassLoader().test(1);
    }

    /**
     * 打印当前方法调用者的调用栈中指定level的Class.
     * @param callerlevel 调用栈的层次. 层次同debug界面
     */
    public void test(int callerlevel) {
        Class cs = Reflection.getCallerClass(callerlevel);
        System.out.println(cs);
    }
}

public class TestMain {
    public static void main(String[] args) {
        new TestGetCallerClassLoader().test(1);
        new TestGetCallerClassLoader().test(2);
    }

}
